package com.dnjn.happiness.biz.api.factory;

import com.dnjn.happiness.biz.api.RemoteCommunicateService;
import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.common.core.model.CommunicateModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
@Component
public class RemoteCommunicateFallbackFactory implements FallbackFactory<RemoteCommunicateService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteCommunicateFallbackFactory.class);
    @Override
    public RemoteCommunicateService create(Throwable throwable) {
        log.error("调用沟通服务失败：" + throwable.getMessage());
        return new RemoteCommunicateService() {
            @Override
            public void updateHappyWhenCommunicating(Long userId, String scoreTime, Integer happinessScores, String source) {
                log.error("updateHappyWhenCommunicating更新沟通记录失败: {}" + throwable.getMessage());
            }

            @Override
            public R<List<CommunicateModel>> getCommunicateListByStatus(String status, String source) {
                return R.fail("获取沟通列表失败: {}" + throwable.getMessage());
            }

            @Override
            public R<Boolean> handleScoreEvent(Long userId, Integer score, String source) {
               return R.fail("更新沟通记录失败: {}" + throwable.getMessage());
            }

            @Override
            public void updateComSurvyId(Long surveyId, Long communicateId, String source) {
                log.error("更新沟通记录失败：{}" + throwable.getMessage());
            }

            @Override
            public R<CommunicateModel> getResult(Long userId, String lastTime, String scoreTime, String source) {
                return R.fail("查询沟通记录失败");
            }

            @Override
            public R<CommunicateModel> getInfoById(Long communicateId, String source) {
                return R.fail("查询沟通记录失败");
            }

            @Override
            public R<Boolean> delCommunicate(Long communicateId, String source) {
                return R.fail("更新沟通记录失败");
            }

            @Override
            public R<Boolean> deleteByStatus(String value, String source) {
                return R.fail("删除沟通记录失败");
            }
            @Override
            public void updateByCommunicateId(Double modeladdResultsScore, Double defultsScore, String format, Long communicateId, String source) {

            }
            @Override
            public void updateCommunicateDeleted(Long communicateId, String source) {
                log.error("更新沟通记录失败：{}" + throwable.getMessage());
            }
        };
    }
}
